<?php
/* @var $this PenerimaanTamuController */
/* @var $model PenerimaanTamu */

$this->breadcrumbs=array(
	'Penerimaan Tamu'
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('penerimaan-tamu-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<?php  $this->renderPartial('_search',array(
	'model'=>$model,
        'Tamu' => $Tamu,
        'Pegawai' => $Pegawai
)); ?>

<?php $this->widget('ext.widgets.grid.AxGridView', array(
	'id'=>'penerimaan-tamu-grid',
	'dataProvider'=>$model->search(),
	//'filter'=>$model,
        'createTopButton' => FALSE,
	'columns'=>array(
		array
                (
                    'name'=>'no_konfirmasi',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    
                ),
                array(
                    'name'=>'tanggal',
                    'value' => 'date_format(date_create($data->tanggal), "d-m-Y")'
                ),
                'KartuTamu.no_kartu',
                array(
                    'name'=> 'Pegawai.nama',
                    'header'=> 'Nama Tujuan',
                    'filter'=>CHtml::activeTextField($Pegawai, 'nama'),
                ),
                array(
                    'name'=> 'Tamu.nama',
                    'header'=> 'Nama Tamu',
                    'filter'=>CHtml::activeTextField(new Tamu, 'nama'),
                ),
                array
                (
                    'name'=>'jadwal_mulai',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->jadwal_mulai!="")?date_format(date_create($data->jadwal_mulai), "H:i:s"):""',
                ),
                array
                (
                    'name'=>'jadwal_selesai',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->jadwal_selesai!="")?date_format(date_create($data->jadwal_selesai), "H:i:s"):""',
                ),
                array
                (
                    'name'=>'jam_datang',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->jam_datang!="") ? date_format(date_create($data->jam_datang), "H:i:s"):""',
                ),
                array
                (
                    'name'=>'lama_tunggu',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                        'value'=>'(strtotime($data->jadwal_mulai) >= strtotime(date("Y-m-d H:i:s")) && $data->status_terima=="menunggu")? date("H:i:s", strtotime($data->jadwal_mulai) - strtotime(date("Y-m-d H:i:s"))): ""',
                ),
                array
                (
                    'name'=>'aktual_mulai',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->aktual_mulai!="") ? date_format(date_create($data->aktual_mulai), "H:i:s"):""',
                ),
                array
                (
                    'name'=>'aktual_selesai',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->aktual_selesai!="")? date_format(date_create($data->aktual_selesai), "H:i:s"):""',
                ),
                array
                (
                    'name'=>'jumlah_tamu',
                    'htmlOptions'=>array('style'=>'text-align: center')
                ),
                array
                (
                    'name'=>'janji',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value'=>'($data->janji==1)? "Y" : "T"'
                ),
                array
                (
                    'name'=>'status_terima',
                    'htmlOptions'=>array('style'=>'text-align: center'),
                    'value' => 'PenerimaanTamu::model()->statusPenerimaan($data->status_terima)'
                ),
		array(
			'class'=>'CButtonColumn',
                        'template' => '{view}',
                        'buttons' => array(
                            'testAje' => array(
                                'label' =>'s'
                            )
                        ),
                        'headerHtmlOptions' => array('class' => 'lastcolumn'),
                        'htmlOptions' => array('class' => 'lastcolumn')
		),
	),
)); 

?>